<?php slot('login') ?>
<?php use_stylesheet("/project_css_js/komentaarid.css") ?>
<?php use_javascript("/project_css_js/js/tofsla_forms.js")?>

<div class="pealkiri">
	<p class="mis"><?php echo $node['pageTitle'] ?></p>
</div>
<div class="tagasisidebox">
	<h1><?php echo __('registreeritud kasutajatele') ?></h1>
	<p><?php echo __('sisenemiseks sisesta oma kasutajanimi ja parool') ?></p>
	<p id="login_errors"></p>
	<div class="parooliconteiner">
		<form method="post" action="<?php echo LinkGen::getInstance(LinkGen::STRUCTURE_ACTIONS)->link(null, array('module' => 'publicUserRegistration', 'action' => 'signIn')) ?>">
			<?php echo $form->renderHiddenFields(true) ?>
			<div class="forms">
				<?php echo $form['username']->render(array('class' => 'sideinput', 'title' => $form->getDefault('username')))?>
			</div>
			<div class="forms">
				<?php echo $form['password']->render(array('class' => 'sideinput', 'title' => '*****', 'value' => '*****'))?>
			</div>

			<!--
			<div class="forms check"><input type="checkbox" name="meelde" id="" value="meelde" /></div>
			<div class="checktext">
				<p><?php echo __('jata meelde') ?></p>
			</div>
			-->
			<div class="clear"></div>
			<div class="sabutton">
				<div class="sabuttonleft"><img src="/project_css_js/img/sbuttonleft.png" width="8" height="20" alt=""/></div>
				<div class="sabuttoncenter"><p><a id="signin_button" href="#"><?php echo __('logi sisse') ?></a></div>
				<div class="sabuttonright"><img src="/project_css_js/img/sbuttonright.png" width="8" height="20" alt=""/></div>
			</div>
			<div class="sabutton">
				<div class="sabuttonleft"><img src="/project_css_js/img/sbuttonleft.png" width="8" height="20" alt=""/></div>
				<div class="sabuttoncenter"><p><a href="<?php echo LinkGen::getInstance(LinkGen::SIGN_IN)->specialLink('passwordReminder') ?>"><?php echo __('uuenda parooli') ?></a></div>
				<div class="sabuttonright"><img src="/project_css_js/img/sbuttonright.png" width="8" height="20" alt=""/></div>
			</div>
			<div class="clear"></div>

		</form>
	</div>
	<div class="abi"><?php echo $node['content'] ?></div>
</div>
<script type="text/javascript">
  $('#signin_button').click(function(e) {
	e.preventDefault();

	var form = $(this).parents('form');
	var action = form.attr('action');

	$.post(action, form.serialize(), function(data) {
	  if(data.code == 500){ // fail
		  $('#login_errors').html(data.message);
	  }else{ // suxass
		window.location = data.redirectLink;
	  }

	},'json');

    return false;
  });
</script>
<?php end_slot() ?>